<template>
    <div>
        <el-table :data="$store.getters['banner/getBanner']" border style="width: 100%">
            <el-table-column prop="id" label="编号" width="180">
            </el-table-column>
            <el-table-column prop="title" label="轮播图标题" width="180">
            </el-table-column>
            <el-table-column label="图片">
                <template slot-scope="item">
                    <div>
                        <img style="width:40px;height: 40px;" :src="item.row.img" alt="">
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="状态">
                <template slot-scope="item">
                    <div>
                        <el-button type="primary" size="mini" plain>{{ item.row.status == 1 ? '启用' : '禁用' }}</el-button>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="item">
                    <div>
                        <el-button type="primary" icon="el-icon-edit" circle size="mini"
                            @click="edit(item.row.id)"></el-button>
                        <el-button type="danger" icon="el-icon-delete" circle size="mini"
                            @click="del(item.row.id)"></el-button>
                    </div>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>

import { bannerdelete } from '../../request/api'
export default {
    data() {
        return {

        }
    },
    methods: {
        // 编辑
        edit(id) {
            this.$emit('edit', id)
        },
        // 删除
        del(id) {
            this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                bannerdelete({ id })
                    .then(res => {
                        if (res.code = 200) {
                            this.$message.success(res.msg)
                            this.$store.dispatch('banner/GetBannerInfo')
                        }else{
                            this.$message.error(res.msg)
                        }
                    })

            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        }
    },
    mounted() {
        console.log(this.$store);
        this.$store.dispatch('banner/GetBannerInfo')
    },
    watch: {},
    computed: {},
    filters: {},
    components: {}
}
</script>
<style scoped></style>